gl renderer: Remove consecutive clip ops
authorTimm Bäder <mail@baedert.org>
Sat, 2 Dec 2017 10:02:31 +0000 (11:02 +0100)
committerTimm Bäder <mail@baedert.org>
Thu, 21 Dec 2017 18:12:31 +0000 (19:12 +0100)
gsk/gl/gskglrenderops.c

index 8fe9e90f185965725705e1696c06a23c51faa812..2741320b2a9f4e028ed893c556b7ccdaa4deb5a7 100644 (file)
@@ -62,12 +62,23 @@ GskRoundedRect
 ops_set_clip (RenderOpBuilder      *builder,
               const GskRoundedRect *clip)
 {
-  RenderOp op;
+  RenderOp *last_op;
   GskRoundedRect prev_clip;
 
-  op.op = OP_CHANGE_CLIP;
-  op.clip = *clip;
-  g_array_append_val (builder->render_ops, op);
+  last_op = &g_array_index (builder->render_ops, RenderOp, builder->render_ops->len - 1);
+
+  if (last_op->op == OP_CHANGE_CLIP)
+    {
+      last_op->clip = *clip;
+    }
+  else
+    {
+      RenderOp op;
+
+      op.op = OP_CHANGE_CLIP;
+      op.clip = *clip;
+      g_array_append_val (builder->render_ops, op);
+    }
 
   if (builder->current_program != NULL)
     builder->program_state[builder->current_program->index].clip = *clip;